//
//  MenuViewController.m
//  ToucheTouche
//
//  Created by Jordan Montel on 09/01/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "MenuViewController.h"


@implementation MenuViewController

@synthesize buttonPlay, buttonScore, buttonHelp, buttonOption, buttonFB, buttonTwitter,buttonRate, buttonContact;;

- (IBAction)likeOrFollowIt:(id)sender {
    webViewController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
    
    if (sender == buttonFB) {
        webViewController .urlString = @"http://www.facebook.com/where.ar.you";
    }
    else if (sender == buttonTwitter) {
        webViewController .urlString = @"http://twitter.com/#!/WhereARyou";
    }    
    
    webViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    [self presentModalViewController:webViewController animated:YES];
    [webViewController release];
}

- (IBAction)rateIt {
    
}

- (IBAction)contactUs {
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setToRecipients:[NSArray arrayWithObject:@"team@applicationDeOuf.fr"]];
    [picker setSubject:@"Information application !"];
    [picker setMessageBody:@"C'est de la bombe !" isHTML:NO];
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    switch (result) {
        case MFMailComposeResultSent:
            NSLog(@"Envoie mail : OK");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Sauvegarde mail : OK");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Echec envoie : OK");
            break;
        case MFMailComposeResultCancelled: 
            NSLog(@"Annulation envoie : OK");
            break;
            
        default:
            break;
    }
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)pushModeGame {
    modeGameViewController = [[ModeGameViewController alloc] initWithNibName:@"ModeGameViewController" bundle:nil];
    modeGameViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:modeGameViewController animated:YES];
    [modeGameViewController release];
}

- (IBAction)pushScore {
    scoreViewController = [[ScoreViewController alloc] initWithNibName:@"ScoreViewController" bundle:nil];
    scoreViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:scoreViewController animated:YES];
    [scoreViewController release];
}

- (IBAction)pushHelp {
    helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
    helpViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:helpViewController animated:YES];
    [helpViewController release];
}

- (IBAction)pushOption {
    optionViewController = [[OptionViewController alloc] initWithNibName:@"OptionViewController" bundle:nil];
    optionViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:optionViewController animated:YES];
    [optionViewController release];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [buttonPlay release];
    [buttonScore release];
    [buttonHelp release];
    [buttonOption release];
    [buttonFB release];
    [buttonTwitter release];
    [buttonRate release];
    [buttonContact release];
    
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [self setButtonPlay:nil];
    [self setButtonScore:nil];
    [self setButtonHelp:nil];
    [self setButtonOption:nil];
    [self setButtonFB:nil];
    [self setButtonTwitter:nil];
    [self setButtonRate:nil];
    [self setButtonContact:nil];
    
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

@end
